package edu.hunau.cxb17.service.impl;

import edu.hunau.cxb17.dao.IUserDao;
import edu.hunau.cxb17.pojo.User;
import edu.hunau.cxb17.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService{

    @Autowired
    private IUserDao userDao;

    @Override
    public User saveUser(User u)throws Exception{
        Integer pk = userDao.saveReturnPk(u);
        u.setId(pk);

        if(2<1){
            throw new Exception("模拟抛出异常...");
        }
        return u;
    }

    @Override
    public List<User> queryByLikeName(String name) {
        return userDao.queryByLikeName(name);
    }
}
